//
//  PictureCell.swift
//  sinazd
//
//  Created by apple on 16/3/12.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit


class PictureCell: UICollectionViewCell {
    
    var imageURL: NSURL? {
        didSet {
            iconView.sd_setImageWithURL(imageURL)
        }
    }
    
    
    //重写构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    //默认实现报错
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //MARK: 设置UI界面
    private func setupUI() {
        contentView.addSubview(iconView)
        //设置约束
        iconView.snp_makeConstraints { (make) -> Void in
            make.edges.equalTo(contentView.snp_edges)
        }
    }
    
    
    //MARK: 懒加载子视图
   // private lazy var iconView: UIImageView = UIImageView()
    
    private lazy var iconView: UIImageView = {
        
        let iv = UIImageView()
        
        iv.contentMode = .ScaleAspectFill
        
        iv.clipsToBounds = true
        
        return iv
        
        
    }()
}

